<?php
	include_once('header.php');
	include_once('menu.php');
	include_once('content.php');
?>
		<h3>Podrobné informácie o ceste</h3>
		<table style="width: 40%;">
		<tr>
			<td><b>Mesto</b></td>
			<td><?php echo $cesta[0]['city'] ?></td>
		</tr>
		<tr>
			<td><b>Štát</b></td>
			<td><?php echo $cesta[0]['country'] ?></td>
		</tr>
		<tr>
			<td><b>Organizácia</b></td>
			<td><?php echo $cesta[0]['organization'] ?></td>
		</tr>
		<tr>
			<td><b>Dátum príchodu</b></td>
			<td><?php echo $cesta[0]['date_of_arrival'] ?></td>
		</tr>
		<tr>
			<td><b>Dátum odchodu</b></td>
			<td><?php echo $cesta[0]['date_of_departure'] ?></td>
		</tr>
		</table>
		<?php
		
		if( $typ_cesty == 'pricestovani' ){
			echo '<p>'.anchor('SluzobneCesty/GetAll/pricestovani','Späť na služobné cesty').'</p>';	
		} else if( $typ_cesty == 'odcestovani' ){
			echo '<p>'.anchor('SluzobneCesty/GetAll/odcestovani','Späť na služobné cesty').'</p>';
		}
		

		echo "<h3>Priradení ľudia</h3>";
		if (isset($priradeni_ludia) && $priradeni_ludia != FALSE){
			echo "<table>";
			echo '<tr><td><b>Meno</b></td><td><b>Priezvisko</b></td><td><b>Emailová adresa</b></td><td>&nbsp;</td></tr>';
			foreach ($priradeni_ludia as $key => $obj) {
				echo '<tr><td>' . $obj->name . '</td><td>' . $obj->surname . '</td><td>' . $obj->email . '</td>';
				echo '<td class="action">';
				if($this->session->userdata('logged_in') && $this->session->userdata('admin')){
					echo anchor('SluzobneCesty/odober/'.$typ_cesty.'/'. $id_cesty .'/'.$obj->person_id, 'Zrušiť',array('class'=>'delete', 'onclick'=>'return confirm(\'Naozaj si prajete odobrať človeka z cesty?\')'));
				}
				echo '&nbsp;</td></tr>';
			} 
			echo "</table>";
		} else {
			echo "<p>Nikto nie je priradený k ceste.</p>";
		}
		if($this->session->userdata('logged_in') && $this->session->userdata('admin')){
		if( isset($clovek_existujuci) ) echo '<p class="error">Človek už je priradený k ceste, nemožete ho ešte raz priradiť.</p>'; 
		if( isset($clovek_pridany) && $clovek_pridany ) echo '<p style="color: green; margin-top: 20px;"><b>Človek bol priradený k ceste.</b></p>';
		else if(isset($clovek_pridany) && !$clovek_pridany) echo '<div class="error">Človek už je priradený k ceste. Dvakrát ho nemôžete priradiť!</div>';
		echo "<h3>Pridať človeka k ceste</h3>";
		if ( isset($errorMeno) ) echo $errorMeno;
		
		if ( isset($options_drop_box) && !empty($options_drop_box) ){
			echo form_open('people/addExisting', array('class'=>'jNice'));
			echo form_fieldset();
			echo '<p>' . form_label('Ľudia', 'ludia');
			echo form_dropdown('ludia', $options_drop_box);
			echo form_submit('pridat','Pridať existujúceho').'</p>';
			echo form_hidden('typ_cesty',$typ_cesty); //tabulka v db
			echo form_hidden('cesta_id',$cesta[0]['id']); //do ktorej cesty
			echo form_fieldset_close();
			echo form_close();
		}
		
		echo form_open('people/search', array('id'=>'search','class'=>'jNice'));
		echo form_fieldset();
		echo '<p>Search' . form_input('str') . '</p>';
		echo form_hidden('typ_cesty',$typ_cesty);//tabulka v db
		echo form_fieldset_close();
		echo form_close();
		
		echo '<div id="search-content"></div>';
			
		echo form_open('people/pridatCloveka', array('class'=>'jNice pridat-noveho-cloveka'));
		echo form_fieldset();
		echo form_error('name');
		echo '<p>'.form_label('Meno*', 'name');
		echo form_input('name', set_value('name')).'</p>';
		echo form_error('surname');
		echo '<p>'.form_label('Priezvisko*', 'surname');
		echo form_input('surname',set_value('surname')).'</p>';

		echo form_error('degree');
		
		echo '<p>'.form_label('Titul pred menom 1', 'degree');
		echo form_input('degree',set_value('degree')).'</p>';
		
		echo '<p>'.form_label('Titul pred menom 2', 'degree');
		echo form_input('degree2',set_value('degree2')).'</p>';
		
		echo '<p>'.form_label('Titul za menom', 'degree');
		echo form_input('degree3',set_value('degree3')).'</p>';

		echo form_error('sex');
		echo '<p>'.form_label('Muž', 'sex');
		echo form_radio('sex','muz').'</p>';
		echo '<p>'.form_label('Žena', 'sex');
		echo form_radio('sex','zena').'</p>';
		echo form_error('sektion');
		echo '<p>'.form_label('Sekcia', 'sektion');
		echo form_input('sektion',set_value('sektion')).'</p>';
		echo form_error('department');
		echo '<p>'.form_label('Oddelenie*', 'department');
		echo form_input('department',set_value('department')).'</p>';
		echo form_error('chair');
		echo '<p>'.form_label('Kancelária', 'chair');		
		echo form_input('chair',set_value('chair')).'</p>';
		echo form_error('email');
		echo '<p>'.form_label('Emailová adresa*', 'email');
		echo form_input('email',set_value('email')).'</p>';
		echo form_error('tel');
		echo '<p>'.form_label('Telefónne číslo', 'tel');
		echo form_input('tel',set_value('tel')).'</p>';
		echo form_error('web_address');
		echo '<p>'.form_label('Webstránka', 'web_address');
		echo form_input('web_address',set_value('web_address')).'</p>';
		echo form_error('is_deployed');
		echo '<p>'.form_label('Je zamestnaný', 'is_deployed');
		echo 'ano'.form_radio('is_deployed','1').'</p>'; 
		echo '<p>nie '.form_radio('is_deployed','0').'</p>';
		echo form_error('date_of_birth');
		echo '<p>'.form_label('Dátum narodenia', 'date_of_birth');
		echo form_input('date_of_birth',set_value('date_of_birth')).'</p>';
		//echo form_hidden('trip_type','xxx'); //trip type
		echo form_hidden('cesta_id',$cesta[0]['id']); //do ktorej cesty
		echo form_hidden('typ_cesty',$typ_cesty); //do ktorej tabulky mam pridat
		echo form_submit('pridat','Pridat');
		
		echo "<small>Údaje označené * sú povinné!</small>";
		
		echo form_fieldset_close();
		echo form_close();
		} //ak je admin prihalseny
	?>
	
<?php
$footer_scripts = '<script type="text/javascript">
jQuery(document).ready(function($) {
    $(\'input[type=text][name=date_of_birth], input[type=text][name=date_of_departure]\').datepicker({ dateFormat: \'yy-mm-dd\', changeMonth: true, changeYear: true, numberOfMonths: 1, showButtonPanel: true, firstDay: 1, showWeek: true, showOtherMonths: true, selectOtherMonths: true, yearRange: \'-150:+0\' });
    $(\'input[type=text][name=degree]\').autocomplete({ source: \'' . site_url('people/getDegree') . '\' });
    $(\'input[type=text][name=degree2]\').autocomplete({ source: \'' . site_url('people/getDegree2') . '\' });
    $(\'input[type=text][name=degree3]\').autocomplete({ source: \'' . site_url('people/getDegree3') . '\' });
    $(\'input[type=text][name=sektion]\').autocomplete({ source: \'' . site_url('people/getSektion') . '\' });
    $(\'input[type=text][name=department]\').autocomplete({ source: \'' . site_url('people/getDepartment') . '\' });
    $(\'input[type=text][name=chair]\').autocomplete({ source: \'' . site_url('people/getChair') . '\' });
});
</script>';
	include_once('footer.php');
?>
